<?php
/*************************************************************************
Class URL
----------------------------------------------------------------
PICKCO CMS Project
Company: ""
Email: admin@pick.vn
Last updated: 23/05/2011
**************************************************************************/
class Pick_Http_Url
{
	// Language for system...
	public $lang = "vn";
	
	function Pick_Http_Url() {
		global $lang;
		$this->lang = $lang;
	}
	function getUrl($module = "", $id = 0, $slug = ""){
		$url = base_url();
		$modules = new Pick_Core_Modules();
		$objModule = $modules->getObjectFromCode($module);
		if(is_object($objModule)){
			$url .= "/".$objModule->getField('slug');
			if($slug!=""){
				$url .= "/".$slug;	
			}
			if($id){
				$url .= "/id/".$id;;	
			}
		}
		return $url;
	}
	function getUrlFull($module = "", $arrOption = array()){
		$url = base_url();
		$modules = new Pick_Core_Modules();
		$objModule = $modules->getObjectFromCode($module);
		if(is_object($objModule)){
			$url .= "/".$objModule->getField('slug');
			foreach( $arrOption as $key=>$val ){
				if(!empty($key) && !empty($val)){
					$url .= "/".$key."/".$val;
				}#endif
			}#endforeach
		}
		return $url;
	}	
	function getLink($op = "index",$lang="vn",$content="") {
		$link = PROTOCOL.DOMAIN."/".(FOLDER?FOLDER."/":"");
		if (URL_TYPE == 1) $link .= "index.php?op=$op&lang=$lang&content=$content";
		else $link .= ($lang!="vn"?"$lang/":"")."$op".($content?"/$content":"").".html";
		return $link;
	}
	function getBranchLink($op = "index",$lang="vn",$module = "detail",$content="introduction",$slug="") {
		$link = PROTOCOL.DOMAIN."/".(FOLDER?FOLDER."/":"");
		if (URL_TYPE == 1) $link .= "index.php?op=$op&lang=$lang&slug=$slug&module=$module&content=$content";
		else $link .= "$lang/$op/$slug/$module/$content".".html";
		return $link;
	}
	function getFullUrlAvatar($folder = '', $type = 'avatar', $fileName){
            return base_url()."/upload/images/". $folder ."/". $type . '/' . $fileName;
	} 		
}
?>